package cn.shentianlan.email;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

public class EmailUtil {
    @Autowired
    private JavaMailSender javaMailSender;

    public void sendSimpleEmail(String to,String subject,String Text){
        SimpleMailMessage message = new SimpleMailMessage();//消息构造器
        message.setFrom("邮箱地址");//发件人
        message.setTo(to);//收件人
        message.setSubject(subject);//主题
        message.setText(Text);//正文
        javaMailSender.send(message);
        System.out.println("邮件发送完毕");
    }

}
